package com.fy.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fy.entity.Channelv;
import com.fy.entity.Result;
import com.fy.entity.Search;
import com.fy.service.IChannelvService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author 晓岩
 * @since 2022-06-14
 */
@RestController
@RequestMapping("/cha")
public class ChannelvController {
    @Autowired
    IChannelvService iChannelvService;

    @RequestMapping("list")
    public Result list(@RequestBody Search search){
        QueryWrapper<Channelv> wrapper = new QueryWrapper<>();
        if(search.getAname()!=null&&!search.getAname().equals("")){
            wrapper.eq("aname",search.getAname());
        }
        if(search.getXname()!=null&&!search.getXname().equals("")){
            wrapper.eq("xname",search.getXname());
        }
        if(search.getTname()!=null&&!search.getTname().equals("")){
            wrapper.eq("tname",search.getTname());
        }
        if(search.getTime1()!=null){
            wrapper.ge("time",search.getTime1());
        }
        if(search.getTime2()!=null){
            wrapper.le("time",search.getTime2());
        }
        if(search.getCname()!=null&&!search.getCname().equals("")) {
            wrapper.like("cname", search.getCname());
        }
        Page<Channelv> page = new Page<>(search.getPage(),search.getPageSize());
        Page<Channelv> page1 = iChannelvService.page(page, wrapper);
        return new Result(200,"",page1);
    }
}
